<?php

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Application\Controller;

use Zend\Form\View\Helper\FormCaptcha;
use Com\Mvc\Controller\BaseController;
use Zend\View\Model\ViewModel;
use Application\Form\LoginForm;

class CaptureController extends BaseController {

	public function __construct(){
		parent::__construct();
	}
	public function indexAction() {
		$form = new LoginForm($this->getRequest()->getBaseUrl().'/captcha');
		return array(
			'loginForm'=>$form
		);
	}
	public function jsonAction()
    {
    	$data = array('k1' => 1, 'k2' => 2);
    	$response = $this->getResponse();
    	$response->setContent(\Zend\Json\Json::encode(array(
    		'data' => $data
    	)));
    	return $response;
    }
	public function generateAction()
	{
		$response = $this->getResponse();
		$form =new LoginForm($this->getRequest()->getBaseUrl().'/captcha');
		$captcha_code = $form->get('captcha');
	    $id = $this->params('id', false);
	    $captcha = new FormCaptcha($captcha_code);
	    echo "<pre>";
	    print_r($captcha);
	    $json['captchahtml'] = $captcha;
	    exit($json);
	}
	
}
